_realname=libxmp
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=4.5.0
pkgrel=1
pkgdesc="Libxmp is a library that renders module files to PCM data. (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
license=('LGPL')
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-python-docutils"
             "${MINGW_PACKAGE_PREFIX}-autotools")
optdepends=("${MINGW_PACKAGE_PREFIX}-unrar")
options=('staticlibs' 'strip')
source=(https://github.com/libxmp/libxmp/archive/refs/tags/libxmp-${pkgver}.tar.gz)
sha256sums=('678e66da8761ff65f1e1f023d3b9125d4d6dd66e2c03c6ddb88455c2271cadd1')

prepare() {
  [[ -d ${srcdir}/build-${MINGW_CHOST} ]] && rm -rf ${srcdir}/build-${MINGW_CHOST}
  mv ${srcdir}/${_realname}-${_realname}-${pkgver} ${srcdir}/build-${MINGW_CHOST} && cd ${srcdir}/build-${MINGW_CHOST}
  autoconf -W none
}

build() {
  cd ${srcdir}/build-${MINGW_CHOST}

  ./configure --enable-static
  
  make
  make docs/libxmp.3
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  install -D -m644 "${srcdir}/build-${MINGW_CHOST}/docs/libxmp.3" "${pkgdir}${MINGW_PREFIX}/share/man/man3/libxmp.3"
  make DESTDIR="${pkgdir}" install
}
